package com.practice.agObjectAndClass007.reloadOverridePolyMorphism;

/**
 * 多态
 */
public class Polymorphism {
    public static void main(String[] args) {
        Animal cat = new Cat();
        Animal dog = new Dog();
        cat.eat();
        dog.eat();

        Cat cat1 = new Cat();
        cat1.work();
        Dog dog1 = new Dog();
        dog1.work();
    }
}

abstract class Animal {
    abstract void eat();
}

class Cat extends Animal {
    @java.lang.Override
    void eat() {
        System.out.println("猫吃鱼");
    }

    public void work(){
        System.out.println("抓老鼠");
    }
}

class Dog extends Animal {
    @java.lang.Override
    void eat() {
        System.out.println("狗吃肉");
    }
    public void work() {
        System.out.println("看家");
    }
}